home *** CD-ROM | disk | FTP | other *** search
- Path: svnews.ubinet.ubs.com!ubszh!ian.johnston@ubs.com
- From: gzhjis@ubszh.net.ch (Ian Johnston (by ubsswop))
- Newsgroups: comp.lang.c++
- Subject: Re: works in Borland but not in Microsuck Visual C++
- Date: 15 Mar 1996 17:02:05 GMT
- Organization: UBS
- Distribution: world
- Message-ID: <4ic7qd$2fa@ubszh.fh.zh.ubs.com>
- References: <4ia6h8$jes@news.vanderbilt.edu>
- NNTP-Posting-Host: nol2179.fh.zh.ubs.com
-
- In article <4ia6h8$jes@news.vanderbilt.edu>, haseltbt@ctrvax.vanderbilt.edu (Bennett Haselton) writes:
-
- |> Dear Abby,
- |>
- |> The following program was written in completely standard C++
- |> and should be portable across platforms. However, it only performs as
- |> expected (i.e. sends two copies of 4 to the standard out stream) in Borland
- |> C++; when compiled in MicroSUCK Visual C++, it outputs 4 followed by a random
- |> integer in the thousands.
- |>
- |> #include <iostream.h>
- |>
- |> struct person {
- |> int age;
- |> };
- |>
- |> struct person* matchPerson( struct person* psnPtr )
- |> {
- |> struct person* ansPtr;
- |> ansPtr->age = psnPtr->age;
- |> cout << ansPtr->age;
- |> cout << ansPtr->age;
- |> return ansPtr;
- |> };
- |>
- |> void main()
- |> {
- |> struct person myperson;
- |> myperson.age = 4;
- |> struct person* k = matchPerson( &myperson );
- |> }
- |>
- |> i was using version 1.0 of Visual C++; i have no knowledge of whether later
- |> Microsuck compilers are capable of handling a program like this properly.
- |> Please avoid buying their products whenever possible if you have not already
- |> resolved to do so.
- |> Is there a further explanation of this anomaly which i did not come
- |> across? As usual, great Microsuck jokes will be mailed to anyone who can
- |> help. Thanks!
-
- The explanation could be that your code is completely wrong.
-
- Try it on a UNIX system, say, and see if it blows up.
-
- Ian
-
-